<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/icon-font.css"/><!--图标-->
    <link rel="stylesheet" href="../../css/info-list.css"/><!--资讯列表-->

    <link rel="stylesheet" href="../../plugin/mescroll/css/mescroll.min.css">

    <title>ABS报价</title>
    <style>

        .placeholder-top {
            background: rgba(255, 255, 255, 0);
            z-index: 20;
        }

        .abs-list-head {
            /*height: 1.72rem;*/
            height: 3rem;
            width: 7.5rem;
        }

        .abs-list-bg {
            top: 0;
            left: 0;
            width: 100%;
            height: 3rem;
            background: linear-gradient(134deg, rgba(87, 161, 255, 1) 0%, rgba(44, 104, 255, 1) 100%);
        }

        .abs-list-bg img {
            margin-top: 0.7rem;
            margin-left: 5rem;
            height: 1.6rem;
            width: 1.64rem
        }

        .abs-list-menu-wrap {
            width: 3rem
        }

        .abs-list-menu-line {
            display: none;
            width: 0.36rem;
            height: 0.06rem;
            background: rgba(255, 255, 255, 1);
            border-radius: 0.04rem;
            top: 0.45rem
        }

        .abs-list-word {
            color: rgba(255, 255, 255, 0.6)
        }

        .abs-list-word-s {
            color: white
        }

        .abs-list-search {
            bottom: 0.4rem;
            left: 0.32rem;
            height: .84rem;
            width: 6.86rem;
            background: rgba(255, 255, 255, 1);
            box-shadow: 0 0 .32rem 0 rgba(0, 0, 0, 0.1);
            border-radius: 0.08rem;
        }

        .abs-list-search span {
            margin-left: .24rem;
        }

        .abs-list-input {
            color: #222222;
            width: 5rem;
            margin-left: 0.22rem;
            height: 0.6rem;
            line-height: 0.4rem;
        }

        .abs-list-content {
            padding: 0.16rem 0.32rem 0 0.32rem;
        }

        .abs-list-tb {
            width: 100%;
            border-collapse: collapse;
        }

        .abs-list-tr-first {
            color: rgba(34, 34, 34, 0.6);
            border-bottom: 1px solid #f6f6f6;
        }

        .abs-list-td-first {
            padding-bottom: 0.26rem;
            min-width: 1.3rem;
        }

        .abs-list-td {
            padding-bottom: 0.26rem;
            min-width: 1.1rem;
        }

        .abs-list-tr {
            color: rgba(34, 34, 34, 0.6);
            border-bottom: 1px solid #f6f6f6;
        }

        .abs-list-area {
            padding-top: 0.84rem;
            /*top: -0.84rem;*/
        }

        .abs-list-select-left {
            background-color: #F8F9FB;
            height: 100%;
            text-align: center;
            color: rgba(34, 34, 34, 0.7);
            position: fixed
        }

        .abs-list-select-left .abs-list-select-n {
            width: 1.68rem;
            height: 0.86rem;
            line-height: 0.86rem;
        }

        .abs-list-select-left .abs-list-select-active {
            color: #222222;
            font-weight: bold;
        }

        .abs-list-select-right {
            padding: 0 0.26rem 0 1.74rem;
        }

        .abs-list-select-right .abs-list-select-sub {
            margin-bottom: 0.32rem;
            color: #222222;
            font-weight: bold;
        }

        .abs-list-right-n {
            text-align: center;
            line-height: 0.56rem;
            color: #191919;
            width: 2.52rem;
            height: 0.56rem;
            background: rgb(247, 247, 247);
            border-radius: 0.04rem;
            box-sizing: border-box;
            padding: 0 .3rem;
        }

        .abs-list-right-active {
            background: rgba(44, 104, 255, 0.07);
            color: #2C68FF;
            border: 1px solid rgba(44, 104, 255, 1);
        }

        .abs-list-search-item {
            padding: 0.26rem 0.32rem;
            border-bottom: 1px solid #f6f6f6;
            color: #222222;
        }

        .abs-list-no {
            height: 3rem;
            background-color: #f6f6f6;
            padding-top: 2rem;
        }

        .abs-list-no-img {
            height: 1.92rem;
            width: 5.2rem;
        }

        .abs-list-no-img img {
            height: 100%;
            width: 100%;
        }

        .abs-list-no-tip {
            color: rgba(34, 34, 34, 0.7);
        }

        .abs-list-content .abs-list-tbody .abs-list-tr:last-child {
            border: none;
        }

        .abs-lis-por {
            z-index: 10;
            height: 0;
        }

        .abs-list-search-content {
            padding-top: 0.54rem;
        }

    </style>
</head>
<body>

<div class="abs-list-main h-100-p flex-column ff400">
    <!--状态栏-->
    <div class="placeholder-top pos-a">
        <!--状态栏-->
        <div class="status-bar pos-f"></div>
        <!--标题栏-->
        <div class="nav-bar pos-f flex-row justify-content-between c-white align-items-center">
            <div class="left-bar" onclick="clickBack()" style="color: #FFFFFF;">
                <span class="iconfont iconfanhui1 fs16"></span>
            </div>
            <div class="flex-column center-bar fs16 ff500 line1 justify-content-center" style="color:white;">
                <div class="center-bar-show">ABS报价</div>
                <div class="center-bar-show flex-row justify-content-between align-items-center abs-list-search" style="width:4.7rem;height:0.56rem;display: none">
                    <div class="flex-row align-items-center">
                        <span class="iconfont iconsousuo-01 fs16" style="color: #9F9F9F"></span>
                        <input class="abs-list-input ml10 fs14" style="width:4rem;" placeholder="搜索债券代码/简称" onclick="searchForcus()">
                        <span class="iconfont iconshanchu fs16 abs-list-del" style="color:#9F9F9F;display: none;" onclick="cancleDel()"></span>
                    </div>
                </div>
            </div>
            <div class="right-bar" onclick="jumpSelect(1)">
                <span class="iconfont iconshaixuan fs16 c-white"></span>
            </div>
        </div>
    </div>


    <div class="flex-1 mescroll scoll-area" id="mescroll">

        <div class="abs-list-head pos-r">

            <div class="abs-list-bg pos-a">
                <img src="../../images/data/abs-bj.png">
            </div>
            <div class="pos-a" style="top:1.8rem;width:100%">
                <div class="abs-list-menu flex-row align-items-center justify-content-center">

                </div>
            </div>
        </div>
        <div class="abs-lis-por pos-r">
            <div class="flex-row justify-content-between align-items-center abs-list-search pos-r">
                <div class="flex-row align-items-center">
                    <span class="iconfont iconsousuo-01 fs16" style="color: #9F9F9F"></span>
                    <input id="abs-list-input" class="abs-list-input fs14" placeholder="搜索债券代码/简称" oninput="searchContent(this)"/>
                    <span class="iconfont iconshanchu fs16 abs-list-del" style="color:#9F9F9F;display: none;padding-left:0.29rem" onclick="cancleDel()"></span>
                </div>
            </div>
        </div>

        <div class="abs-list-area bg-white pos-r">
            <div class="abs-list-content">

            </div>
        </div>

        <div class="abs-list-search-content  bg-white" style="display: none;">
        </div>
    </div>


</div>

<div class="abs-list-select h-100-p bg-white" style="display:none">
    <div class="placeholder-top">
        <!--状态栏-->
        <div class="bg-main status-bar pos-f"></div>
        <!--导航栏-->
        <div class="bg-main nav-bar pos-f flex-row justify-content-between c-white align-items-center">
            <div class="left-bar" onclick="jumpSelect(2)">
                <span class="iconfont iconguanbi fs16"></span>
            </div>
            <div class="center-bar fs16 ff500 flex-column align-items-center">
                筛选
            </div>
            <div class="right-bar">
            </div>
        </div>
    </div>

    <!--筛选主体-->
    <div class="flex-column">
        <div class="flex-1 flex-column">
            <div class="flex-row">
                <div class="abs-list-select-left flex-column">
                </div>
                <div class="flex-column bg-white" style="padding-bottom: 2rem">
                    <div class="abs-list-select-right  flex-1 scoll-y">
                    </div>
                </div>
            </div>
        </div>
        <div class="flex-row align-items-center justify-content-center bg-white" style="height:1rem;width:7.5rem;border-top:1px solid rgba(0,0,0,0.15);position:fixed;bottom:0;">
            <div style="padding:0.2rem 0.8rem;background-color: #F5F5F5;color:#222222;" onclick="screenReset()">重置</div>
            <div style="margin-left:0.24rem;padding:0.2rem 1.9rem;background-color: #2C68FF;color:#FFFFFF;" onclick="screenConfirm()">确定</div>
        </div>
    </div>

</div>

</body>
<!--这四个文件的引入必须按照顺序-->
<script src="../../js/dict.js"></script>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/checkJsBridge.js"></script>
<script src="../../js/utils.js"></script>
<script src="../../js/api.js"></script>
<!--这四个文件的引入必须按照顺序-->
<script src="../../js/date.js"></script>
<script src="../../js/icon-font.js"></script><!--用于彩色字体图标-->
<script src="../../js/touchRefresh.js"></script>
<script src="../../js/template.js"></script>
<script src="../../js/constant.js"></script>

<script src="../../plugin/mescroll/js/mescroll.min.js"></script>
<script>
  let meScroll
  let pm = {
      limitCount: 20,
      pageNum: 1,
      timeFrom: null,
      idFrom: null,
      timeTo: null,
      idTo: null,
      searchId:'',
      searchWord:'',
      isFirst:false,
      isScroll: true,
      quotationType: 1,  // 0: 活跃平台报价， 1 报价机构报价
      type: 0, // 0: 按 filter 里的筛选条件进行筛选， 2: 按 search 里指定债券id进行筛选
      filter: {
        basicAssets: [],
        priorityClass: [],
        issuerRating: [],
        bondRatingMatch: [],
        secuMarkets: [],
        terms: []
      },
      search: {
        securityId: ''
      },
      code: '100',
      keyWord: ''
    },
    authorized = false, // 控制是否有权限的按钮
    isLogin = false,
    tableList = [{name: '报价机构', code: '100', quotationType: 1}, {name: '活跃市场', code: '101', quotationType: 0}],
    filter = JSON.parse(JSON.stringify(pm.filter)), tempBasicAssets = JSON.parse(JSON.stringify(basicAssets)),  //基础资产
    tempTerms = JSON.parse(JSON.stringify(terms)), // 剩余期限
    tempIssuerRating = JSON.parse(JSON.stringify(issuerRating)), //主体评级
    tempBondRatingMatch = JSON.parse(JSON.stringify(bondRatingMatch)), // 债项评级
    tempPriorityClass = JSON.parse(JSON.stringify(priorityClass)), // 分层级别
    tempSecuMarkets = JSON.parse(JSON.stringify(secuMarkets)) // 交易场所


  function initPage(params) {
    //状态栏自适应
    Utils.sbhAdaptive()
    isLogin = !user.isGuest
    loadTable()
    pm.keyWord = params.key
    pm.searchId = params.id
    pm.searchWord = params.securityName
    if (pm.keyWord) {
      pm.isFirst = true
      $('#abs-list-input').val(pm.keyWord)
      searchContent()
    }else if(pm.searchId){
      pm.isFirst = true
      goToDetail(pm.searchId,pm.searchWord)
    }

    //下拉刷新、滚动加载
    meScroll = Template.createMeScroll({
      id: 'mescroll', //区域ID
      pageNum: 1,
      downCallback: downCallback, //下拉刷新入口
      upCallback: quotations //滚动加载入口
    })
  }

  function reLoadPage() {
    isLogin = !user.isGuest
    loadTable()
    downCallback()
  }

  function downCallback() {

    assembleMenu(pm.code, pm[pm.code].quotationType)

    if(!pm.isFirst){
      quotations()
    }
    pageScroll(quotations)

    loadNav()
    loadSelect()
    scrollWindow()
  }

  function loadTable() {
    tableList.forEach(function (item) {
      $('.abs-list-content').append(`<div class="abs-list-menu-content abs-list-${item.code}"></div>`)
      if (item.code === pm.code) {
        $('.abs-list-menu').append(`<div class="abs-list-menu-wrap flex-column align-items-center pos-r" onclick="tabChange(${item.code})"><div class="abs-list-word abs-list-word-s abs-list-word${item.code}">${item.name}</div><div class="abs-list-menu-line pos-a" style="display: block"></div></div>`)
      } else {
        $('.abs-list-menu').append(`<div class="abs-list-menu-wrap flex-column align-items-center pos-r" onclick="tabChange(${item.code})"><div class="abs-list-word abs-list-word${item.code}">${item.name}</div><div class="abs-list-menu-line pos-a"></div></div>`)
      }
      assembleMenu(item.code, item.quotationType)
    })
  }

  function tabChange(code) {
    $('.abs-list-word').removeClass('abs-list-word-s')
    $('.abs-list-word' + code).addClass('abs-list-word-s')
    $('.abs-list-menu-line').hide()
    $('.abs-list-word' + code).next().show()
    $('.abs-list-menu-content').hide()
    $('.abs-list-' + code).show()
    $('.more').hide()
    $('.more' + code).show()
    pm.code = code

    if (pm.type === 2) {
      jumpSelect(4)
      return false
    }
    if ($('.abs-list-' + code).html() === '') {
      quotations()
    }
  }

  function assembleMenu(code, quotationType) {
    pm[code] = {
      limitCount: 100,
      pageNum: 1,
      timeFrom: null,
      idFrom: null,
      timeTo: null,
      idTo: null,
      isScroll: true,
      quotationType: quotationType,
      type: 0, // 0: 按 filter 里的筛选条件进行筛选， 2: 按 search 里指定债券id进行筛选
      filter: {
        basicAssets: [],
        priorityClass: [],
        issuerRating: [],
        bondRatingMatch: [],
        secuMarkets: [],
        terms: []
      },
      search: {
        securityId: ''
      },
      code: code
    }
  }

  // ABS报价-获取ABS报价
  function quotations() {
    let code = pm.code
    let absServer = isLogin ? Server.absList.userQuotations : Server.absList.quotations
    absServer({
      commons: {},
      datas: {
        limitCount: 10,
        pageNum: pm[code].pageNum,
        timeFrom: null,
        idFrom: null,
        timeTo: pm[code].timeTo,
        idTo: pm[code].idTo,
        isScroll: pm[code].isScroll,
        quotationType: pm[code].quotationType,
        type: pm.type, // 0: 按 filter 里的筛选条件进行筛选， 2: 按 search 里指定债券id进行筛选
        filter: pm.filter,
        search: {
          securityId: pm.search.securityId
        },
      },
    }).then(function (data) {
      pm.isFirst = false
      let htmlStr = ''
      authorized = data.data.authorized
      if (pm[code].pageNum === 1) {
        $('.abs-list-' + code).html('<table class="abs-list-tb"><tbody class="abs-list-tbody"><tr class=\'abs-list-tr-first fs12\'><td class=\'abs-list-td-first\'>债券名称</td> <td class=\'abs-list-td\'>Bid</td> <td class=\'abs-list-td\'>Ofr</td> <td class=\'abs-list-td\'>估值</td> <td class=\'abs-list-td\'>报价方</td> <td class=\'abs-list-td\' style="min-width:1.3rem;">报价时间</td></tr></tbody></table>')
      }
      data.data.items.forEach(function (item) {
        htmlStr += dealTableInfo(item)
      })
      if (data.data.items && data.data.items.length > 0) {
        pm[code].timeTo = data.data.items[data.data.items.length - 1].createTime
        pm[code].idTo = data.data.items[data.data.items.length - 1].id
        //pm[code].isScroll = true
      } else {
        //pm[code].isScroll = false
        //$('.more' + code).html('暂无更多')
      }
      pm[pm.code].pageNum++
      $('.abs-list-' + code).find('.abs-list-tbody').append(htmlStr)

      meScroll.endSuccess(data.data.items.length, data.data.items.length === 10)
    }).catch((error) => {
      meScroll.endErr()
    })
  }

  function dealTableInfo(item) {
    let htmlStr = ''
    let jsonStr = JSON.stringify({
      id:item.id,
      securityId: item.securityId,
      securityCode: item.securityCode,
      type: item.type,
      securityName: item.securityName,
      bid:item.bid,
      bidVol:item.bidVol,
      ofr:item.ofr,
      ofrVol:item.ofrVol,
      instName:item.instName,
      traderName:item.traderName,
      traderType:item.traderType,
      traderUserId:item.traderUserId
    })
    htmlStr += '<tr class=\'abs-list-tr fs12\' onclick=\'jumpDetail(' + jsonStr + ')\'>'
    htmlStr += '<td style=\'padding: 0.16rem 0;max-width:1.3rem;\'>'
    htmlStr += '<div class=\'ff500 c-222 line1 \'>' + item.securityName + '</div>'
    htmlStr += '<div class=\'fs11 line1 \' style=\'color:rgba(34,34,34,0.45)\'>' + (item.securityCode ? item.securityCode : '-') + '</div>'
    htmlStr += '</td>'
    htmlStr += '<td style=\'padding: 0.16rem 0;max-width:0.5rem \'>'
    htmlStr += '<div class=\'fs14 \' style=\'color:#00AE1F\'>' + (item.bid ? item.bid : '-') + '</div>'
    htmlStr += '<div class=\'fs12 line1 \' style=\'color:rgba(34,34,34,0.45)\'>' + (item.bidVol ? item.bidVol : '-') + '</div>'
    htmlStr += '</td>'
    htmlStr += '<td style=\'padding: 0.16rem 0;\'>'
    htmlStr += '<div class=\'\' style=\'color:#EC3E33\'>' + (item.ofr ? item.ofr : '-') + '</div>'
    htmlStr += '<div class=\'fs12\' style=\'color:rgba(34,34,34,0.45)\'>' + (item.ofrVol ? (item.ofrVol / 10000 + '万') : '-') + '</div>'
    htmlStr += '</td>'
    // 估值 iconsuo
    if (authorized) {
      htmlStr += '<td class=\'fs12\' style=\'padding: 0.16rem 0;color:rgba(34,34,34,0.45);\'>' + (item.cbYield ? item.cbYield : '-') + '</td>'
      htmlStr += '<td style=\'padding: 0.16rem 0;max-width: 1rem;\'>'
      htmlStr += '<div class=\'fs13 c-222 line2 \'>' + (item.instName ? item.instName : '-') + '</div>'
      htmlStr += '<div class=\'fs11 line2 \' style=\'color: #1E7FDD\'>' + (item.traderName ? item.traderName : '-') + '</div>'
      htmlStr += '</td>'
    } else {
      htmlStr += '<td class=\'fs12\' style=\'padding: 0.16rem 0;color:rgba(34,34,34,0.45);text-align: center\' onclick="unClock()"><span class="iconfont iconsuo fs14" style="color: #2C68FF"></span></td>'
      htmlStr += '<td class="fs12 pos-r" style=\'padding: 0.16rem 0;color: #2C68FF;text-align: left;left: -0.3rem\'  onclick="unClock()"> 立即解锁 </td>'
    }


    htmlStr += '<td class=\'fs11 c-222\' style=\'padding: 0.16rem 0; \'>' + (item.createTime ? DateUtils.int2Str(item.createTime, 'yyyy-MM-dd') : '') + '</td>'
    htmlStr += '</tr>'
    return htmlStr
  }

  function jumpSelect(val) {
    if (1 === val) {
      $('.abs-list-main').hide()
      $('.abs-list-select').show()
    } else if (2 === val) { // 点击关闭
      basicAssets = JSON.parse(JSON.stringify(tempBasicAssets))  //基础资产
      terms = JSON.parse(JSON.stringify(tempTerms)) // 剩余期限
      issuerRating = JSON.parse(JSON.stringify(tempIssuerRating)) //主体评级
      bondRatingMatch = JSON.parse(JSON.stringify(tempBondRatingMatch)) // 债项评级
      priorityClass = JSON.parse(JSON.stringify(tempPriorityClass)) // 分层级别
      secuMarkets = JSON.parse(JSON.stringify(tempSecuMarkets)) // 交易场所
      $('.abs-list-main').show()
      $('.abs-list-select').hide()
    } else if (3 === val) { // 点击确定时候触发
      pm.type = 0
      pm.search.securityId = ''
      $('.abs-list-main').show()
      $('.abs-list-select').hide()
      $('.abs-list-search-content').hide()
      $('.scoll-area').animate({scrollTop: 0}, 100) // 当点击确定,调用查询接口
      pm[pm.code].pageNum = 1 // 初始化数据
      pm[pm.code].timeTo = null
      pm[pm.code].idTo = null
      quotations()
    } else if (4 === val) {
      pm.type = 2
      pm[pm.code].pageNum = 1 // 初始化数据
      pm[pm.code].timeTo = null
      pm[pm.code].idTo = null
      quotations()
    } else if (5 === val) { // 点击X的时候触发
      pm.type = 0
      pm.search.securityId = ''
      tableList.forEach(function (item) {
        pm[item.code].pageNum = 1 // 初始化数据
        pm[item.code].timeTo = null
        pm[item.code].idTo = null
      })
      $('.scoll-area').animate({scrollTop: 0}, 100)
      quotations()
    }
    loadSelect()

  }


  function loadNav() {
    $('.abs-list-select-left').html('')
    // 左侧数据
    nav.forEach(function (item, index) {
      if (0 === index) {
        $('.abs-list-select-left').append(`<div class="abs-list-select-n fs500 abs-list-select-active" onclick="menuClick(${index})">${item.text}</div>`)
      } else {
        $('.abs-list-select-left').append(`<div class="abs-list-select-n" onclick="menuClick(${index})">${item.text}</div>`)
      }
    })
  }

  function loadSelect() {
    $('.abs-list-select-right').html('')
    // 基础资产  basicAssets
    let htmlStr = '<div class=\'abs-list-select-part\'><div class=\'abs-list-select-sub ml10 fs16\'>基础资产</div>'
    htmlStr += '<div class=\'flex-row flex-wrap\'>'
    basicAssets.forEach(function (item) {
      htmlStr += '<div class=\'abs-list-right-n ml10 mb10 fs13 line1 ' + (item.select ? 'abs-list-right-active' : '') + ' \' onclick="basicClick(\'' + item.value + '\')">' + item.text + '</div>'
    })
    htmlStr += '</div></div>'
    $('.abs-list-select-right').append(htmlStr)

    // 剩余期限 terms
    htmlStr = '<div class=\'abs-list-select-part\'><div class=\'abs-list-select-sub ml10 fs16 mt15 \'>剩余期限</div>'
    htmlStr += '<div class=\'flex-row flex-wrap\'>'
    terms.forEach(function (item) {
      htmlStr += '<div class=\'abs-list-right-n ml10 mb10 fs13 line1  ' + (item.select ? 'abs-list-right-active' : '') + ' \' onclick="termsClick(\'' + item.value + '\',this)">' + item.text + '</div>'
    })
    htmlStr += '</div></div>'
    $('.abs-list-select-right').append(htmlStr)

    // 主体评级 issuerRating
    htmlStr = '<div class=\'abs-list-select-part\'><div class=\'abs-list-select-sub ml10 fs16 mt15 \'>主体评级</div>'
    htmlStr += '<div class=\'flex-row flex-wrap\'>'
    issuerRating.forEach(function (item) {
      htmlStr += '<div class=\'abs-list-right-n ml10 mb10 fs13 line1  ' + (item.select ? 'abs-list-right-active' : '') + ' \' onclick="issuerRateClick(\'' + item.value + '\',this)">' + item.text + '</div>'
    })
    htmlStr += '</div></div>'
    $('.abs-list-select-right').append(htmlStr)
    // 债项评级 bondRatingMatch
    htmlStr = '<div class=\'abs-list-select-part\'><div class=\'abs-list-select-sub ml10 fs16  mt15 \'>债项评级</div>'
    htmlStr += '<div class=\'flex-row flex-wrap\'>'
    bondRatingMatch.forEach(function (item) {
      htmlStr += '<div class=\'abs-list-right-n ml10 mb10 fs13 line1  ' + (item.select ? 'abs-list-right-active' : '') + ' \' onclick="bondRateClick(\'' + item.value + '\',this)">' + item.text + '</div>'
    })
    htmlStr += '</div></div>'
    $('.abs-list-select-right').append(htmlStr)
    // 分层级别 priorityClass
    htmlStr = '<div class=\'abs-list-select-part\'><div class=\'abs-list-select-sub ml10 fs16 mt15 \'>分层级别</div>'
    htmlStr += '<div class=\'flex-row flex-wrap\'>'
    priorityClass.forEach(function (item) {
      htmlStr += '<div class=\'abs-list-right-n ml10 mb10 fs13 line1  ' + (item.select ? 'abs-list-right-active' : '') + ' \' onclick="priorityClick(\'' + item.value + '\',this)">' + item.text + '</div>'
    })
    htmlStr += '</div></div>'
    $('.abs-list-select-right').append(htmlStr)
    // 交易场所 secuMarkets
    htmlStr = '<div class=\'abs-list-select-part\'><div class=\'abs-list-select-sub ml10 fs16 mt15 \'>交易场所</div>'
    htmlStr += '<div class=\'flex-row flex-wrap\'>'
    secuMarkets.forEach(function (item) {
      htmlStr += '<div class=\'abs-list-right-n ml10 mb10 fs13 line1  ' + (item.select ? 'abs-list-right-active' : '') + ' \' onclick="secuMarketsClick(\'' + item.value + '\',this)">' + item.text + '</div>'

    })
    htmlStr += '</div></div>'
    $('.abs-list-select-right').append(htmlStr)
  }


  // 点击基础信息
  function basicClick(val) {
    let flag = false
    $.each(basicAssets, function (i, item) {
      if (val === 'all') { // 如果是选择不限
        if (item.value === val) {
          item.select = true
        } else {
          item.select = false
        }
      } else {
        if (item.value === parseInt(val)) {
          item.select = !item.select
        }
        if (item.select) { // 如果含有选中的,则说明不必要选择不限
          flag = true
        }
      }
    })
    basicAssets[0].select = !flag
    loadSelect()
  }

  // 点击剩余期限
  function termsClick(val) {
    let flag = false
    $.each(terms, function (i, item) {
      if (val === 'all') { // 如果是选择不限
        if (item.value === val) {
          item.select = true
        } else {
          item.select = false
        }
      } else {
        if (item.value === parseInt(val)) {
          item.select = !item.select
        }
        if (item.select) { // 如果含有选中的,则说明不必要选择不限
          flag = true
        }
      }
    })
    terms[0].select = !flag
    $('.abs-list-select-right').html('')
    loadSelect()
  }

  //  主体评级 issuerRating
  function issuerRateClick(val) {
    let flag = false
    $.each(issuerRating, function (i, item) {
      if (val === 'all') { // 如果是选择不限
        if (item.value === val) {
          item.select = true
        } else {
          item.select = false
        }
      } else {
        if (item.value === val) {
          item.select = !item.select
        }
        if (item.select) { // 如果含有选中的,则说明不必要选择不限
          flag = true
        }
      }
    })
    issuerRating[0].select = !flag
    $('.abs-list-select-right').html('')
    loadSelect()
  }

  //债项评级
  function bondRateClick(val) {
    let flag = false
    $.each(bondRatingMatch, function (i, item) {
      if (val === 'all') { // 如果是选择不限
        if (item.value === val) {
          item.select = true
        } else {
          item.select = false
        }
      } else {
        if (item.value === val) {
          item.select = !item.select
        }
        if (item.select) { // 如果含有选中的,则说明不必要选择不限
          flag = true
        }
      }
    })
    bondRatingMatch[0].select = !flag
    $('.abs-list-select-right').html('')
    loadSelect()
  }

  //分层级别
  function priorityClick(val) {
    let flag = false
    $.each(priorityClass, function (i, item) {
      if (val === 'all') { // 如果是选择不限
        if (item.value === val) {
          item.select = true
        } else {
          item.select = false
        }
      } else {
        if (item.value === parseInt(val)) {
          item.select = !item.select
        }
        if (item.select) { // 如果含有选中的,则说明不必要选择不限
          flag = true
        }
      }
    })
    priorityClass[0].select = !flag
    $('.abs-list-select-right').html('')
    loadSelect()
  }

  //交易场所
  function secuMarketsClick(val) {
    let flag = false
    $.each(secuMarkets, function (i, item) {
      if (val === 'all') { // 如果是选择不限
        if (item.value === val) {
          item.select = true
        } else {
          item.select = false
        }
      } else {
        if (item.value === val) {
          item.select = !item.select
        }
        if (item.select) { // 如果含有选中的,则说明不必要选择不限
          flag = true
        }
      }
    })
    secuMarkets[0].select = !flag
    $('.abs-list-select-right').html('')
    loadSelect()
  }

  function getSelectInfo() {
    filter = JSON.parse(JSON.stringify(pm.filter))
    filter.basicAssets = []
    basicAssets.forEach(function (it) {
      if (it.select && it.value === 'all') {
        filter.basicAssets = []
      } else if (it.select && it.value !== 'all') {
        filter.basicAssets.push(it.value)
      }
    })
    filter.terms = []
    terms.forEach(function (it) {
      if (it.select && it.value === 'all') {
        filter.terms = []
      } else if (it.select && it.value !== 'all') {
        filter.terms.push(it.value)
      }
    })
    filter.issuerRating = []
    issuerRating.forEach(function (it) {
      if (it.select && it.value === 'all') {
        filter.issuerRating = []
      } else if (it.select && it.value !== 'all') {
        filter.issuerRating.push(it.value)
      }
    })
    filter.bondRatingMatch = []
    bondRatingMatch.forEach(function (it) {
      if (it.select && it.value === 'all') {
        filter.bondRatingMatch = []
      } else if (it.select && it.value !== 'all') {
        filter.bondRatingMatch.push(it.value)
      }
    })
    filter.priorityClass = []
    priorityClass.forEach(function (it) {
      if (it.select && it.value === 'all') {
        filter.priorityClass = []
      } else if (it.select && it.value !== 'all') {
        filter.priorityClass.push(it.value)
      }
    })
    filter.secuMarkets = []
    secuMarkets.forEach(function (it) {
      if (it.select && it.value === 'all') {
        filter.secuMarkets = []
      } else if (it.select && it.value !== 'all') {
        filter.secuMarkets.push(it.value)
      }
    })
  }

  // 点击筛选的重置
  function screenReset() {
    basicClick('all')
    termsClick('all')
    issuerRateClick('all')
    bondRateClick('all')
    priorityClick('all')
    secuMarketsClick('all')
  }

  // 点击筛选里面的确认
  function screenConfirm() {
    getSelectInfo()
    pm.type = 0
    pm.search.securityId = ''
    pm.filter = JSON.parse(JSON.stringify(filter))
    tempBasicAssets = JSON.parse(JSON.stringify(basicAssets))  //基础资产
    tempTerms = JSON.parse(JSON.stringify(terms)) // 剩余期限
    tempIssuerRating = JSON.parse(JSON.stringify(issuerRating)) //主体评级
    tempBondRatingMatch = JSON.parse(JSON.stringify(bondRatingMatch)) // 债项评级
    tempPriorityClass = JSON.parse(JSON.stringify(priorityClass)) // 分层级别
    tempSecuMarkets = JSON.parse(JSON.stringify(secuMarkets)) // 交易场所
    jumpSelect(3) // 关闭筛选框，显示列表页面
  }

  // ABS数据查询
  function searchContent() {
    $('.abs-list-search-content').show()
    $('.abs-list-area').hide()
    if ($('#abs-list-input').val()) {
      $('.abs-list-del').show()

      Server.absList.searchByKey({
        commons: {},
        datas: {
          keyWord: $('#abs-list-input').val(),
          securityType: 'ABS',
          filterExpired: false
        }
      }).then(function (data) {
        let htmlStr = ''
        if (data.data && data.data.length > 0) {
          data.data.forEach(function (item) {
            htmlStr += '<div class=\'abs-list-search-item fs15 line1\' onclick=\'goToDetail("' + item.id + '","' + item.securityName + '")\'>' + item.securityCode + '    ' + item.securityName + '</div>'
          })
        } else {
          htmlStr = '<div class=\'abs-list-no flex-column  align-items-center\'><div class=\'abs-list-no-img\'><img src=\'../../images/data/abs-no-data.png\' /></div><div class=\'abs-list-no-tip fs12\'>当前暂无该债券的报价信息！</div></div>'
        }
        $('.abs-list-search-content').html(htmlStr)
      })
    } else {
      $('.abs-list-del').hide()
    }
  }

  // 点击搜索后的
  function goToDetail(id, name) {
    $('#abs-list-input').val(name)
    $('.abs-list-search-content').hide()
    $('.abs-list-area').show()
    $('.abs-list-del').show()
    pm.search.securityId = id
    jumpSelect(4)

  }

  function cancleDel() {
    // if($('.abs-list-input').val()){
    $('#abs-list-input').val('')
    $('.abs-list-area').show()
    $('.abs-list-search-content').hide()
    $('.abs-list-del').hide()
    jumpSelect(5)
    // }
  }


  function pageScroll(callback) {
    //需要特殊处理的滚动区域，需要放在scroller元素区域内
    $('.scoll-area').on('scroll', function () {
      let scrollTop = $(this).scrollTop()
      dealHead(scrollTop)
    })
  }

  //处理状态栏滚动效果
  function dealHead(scrollTop) {
    let currStop = 0
    if (scrollTop < 100) {
      currStop = scrollTop
      $('.center-bar-show').eq(0).show()
      $('.center-bar-show').eq(1).hide()
    } else {
      currStop = 100
      $('.center-bar-show').eq(0).hide()
      $('.center-bar-show').eq(1).show()
    }
    $('.placeholder-top').css({
      'background': 'linear-gradient(134deg, rgba(87, 161, 255, ' + currStop / 100 + ')  0%, rgba(44, 104, 255, ' + currStop / 100 + ') 100%)'
    })

  }

  // 点击头部的搜索框，聚焦到下方搜索框
  function searchForcus() {
    $('.scoll-area').animate({scrollTop: 0}, 100)
    $('#abs-list-input').focus()
  }


  function scrollWindow() {
    $(window).on('scroll', function () {
      let scrollTop = $(this).scrollTop()
      $('.abs-list-select-right').find('.abs-list-select-part').each(function (index) {
        let offtop = $(this).offset().top  // 每个 class 距离顶部的距离 （固定 偏移量）
        let h = $(this).height() + offtop //自身div的高度 + 偏移量
        if ((scrollTop + 110) >= offtop && scrollTop <= h) {
          $('.abs-list-select-n').eq(index).addClass('fs500 abs-list-select-active')
        } else {
          $('.abs-list-select-n').eq(index).removeClass('fs500 abs-list-select-active')
        }
      })

    })
  }

  // 点击筛选的左边的菜单
  function menuClick(val) {
    // 64 724 965 1169
    // 64 650 900
    $('body,html').animate({scrollTop: $('.abs-list-select-right').find('.abs-list-select-part').eq(val).offset().top - 64}, 100)
  }

  // 跳转至abs详情
  function jumpDetail(data) {
    console.log(data)
    jsBridge.openWindow('html/data/abs-detail.html?obj=' + JSON.stringify(data) + '&type=' + pm[pm.code].quotationType + '&authorized=' + authorized,
      {}, {
        noBar: false
      })
  }

  // 解锁
  function unClock() {
    jsBridge.openWindow('html/data/abs-power.html', {}, {noBar: false})
    stopBubbling()
  }


</script>
</html>
